<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cart</title>
<link type="text/css" rel="stylesheet" href="css/gobal.css" />
<link type="text/css" rel="stylesheet" href="css/list.css" />
<script src="js/jquery1.7.2.js" type="text/javascript" ></script>
</head>
<body>
<div id="container">
	<div id="header">
    	<div class="soh1"><img src="css/images/header.gif"></div>
        <div class="soh2">
        	<div class="ssoh21"><p>购物车<label id="msg"></label></p></div>
        	<div class="ssoh22">
        		<p>当前用户：${user==null?"游客":user}→<a href="/JspCart/userServlet?opt=exit">退出</a>→<a href="index.jsp">返回主页</a></p>
        	</div> 
    	</div>
    </div>

    <div id="main">
    	<div class="table">
	            <div class="trh">
                	<div class="tdh">编号</div><div class="tdh">分类</div><div class="tdh">名称</div><div class="tdh">价格</div>
                    <div class="tdh">厂商</div><div class="tdh">数量</div><div class="tdh">修改</div><div class="tdh">删除</div>
                </div>
    		<c:forEach items="${goodsList }" var="goods">
				<div class="tr">
                	<div class="td">${goods.id }</div><div class="td">${goods.sort }</div><div class="td">${goods.name }</div>
                    <div class="td">${goods.price }</div><div class="td">${goods.brand }</div>
					<div class="tdform">
					<form action ="/JspCart/cartServlet?opt=update" method="post">
						<div class="td">
                    		<input type="hidden" name="id" value="${goods.id}" />
                    		<input type="text" style="width:40px" name="num" value="${goods.num }"/></div>
                    	<div class="td">
                    		<input type="submit" style="background-image:url(css/images/cart.gif);height:100%;width:80px;" value="" title="put into your cart"/>
                    	</div>
                    </form>
                    <div class="td"><a href="/JspCart/cartServlet?opt=delete&id=${goods.id }">删除</a></div>
                    </div>
                </div>
    		</c:forEach>
            <div class="tr">
            	<div class="tdf1">
            		合计：￥${sum }----------------购物车(${size }/50)----------------${pageNum }/${pageCount }|
            		<a href="/JspCart/hardwareServlet?opt=sort&sort=${sort }&pageNum=1">首页|</a>
            		<a href="/JspCart/hardwareServlet?opt=sort&sort=${sort }&pageNum=${pageNum-1}">上一页|</a>
            		<a href="/JspCart/hardwareServlet?opt=sort&sort=${sort }&pageNum=${pageNum+1}">下一页|</a>
            		<a href="/JspCart/hardwareServlet?opt=sort&sort=${sort }&pageNum=${pageCount}">最后一页</a>
            		</div>
            	<div class="tdf2">
                    <form id="form" action="/JspCart/orderServlet?opt=show" method="post">
                        <div class="sotf21">
                            <select id="page" style="width:70px" name="pageNum">
                                <option value="0">请选择</option>
                            </select>页
                        </div>
                        <div class="sotf22"><input type="submit" style="background-image:url(css/images/go.gif);height:100%;width:95px;" value="" title="Go" ></div>
                    </form>
                </div>
            </div>
        </div>
        <div class="table1">
       		<c:forEach items="${hardwareSort }" var="hardware">
    			<a href="/JspCart/hardwareServlet?opt=sort&sort=${hardware }">${hardware }</a><br>
    		</c:forEach>
        </div>
    </div>
<jsp:include page="/footer.jsp"/>
</div>
<script type="text/javascript">
$(function(){
	$("form").submit(function(){
		var size = ${size };
		if(size==0){
			$("#msg").html(",空空如也,买点什么吧...");
			return false;
		}else{
			return true;
		}
			
	});
});
</script>
</body>
</html>